﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;
using TelecoSystems.Modules.Customers.Views;
using TelecoSystems.Infrastructure;
using TelecoSystems.Web.Services.Customers;
using System.Collections.Generic;

namespace TelecoSystems.Modules.Customers
{
    public class CustomersModule : IModule
    {
        private readonly IRegionManager regionManager;
        private readonly IUnityContainer unityContainer;
        private const string MODULE_NAME = "Customers"; 

        public CustomersModule(IRegionManager _regionManager, IUnityContainer _unityContainer)
        {
            regionManager = _regionManager;
            unityContainer = _unityContainer;
        }

        public void Initialize()
        {
            unityContainer.RegisterType<CustomersDomainContext>(new InjectionConstructor());                                            
            
            IRegion region = regionManager.Regions[RegionNames.MainRegion];
            CustomersModuleView cmView = this.unityContainer.Resolve<CustomersModuleView>();
            region.Add(cmView, cmView.GetType().Name);
            region.Activate(cmView);

            region = regionManager.Regions[MODULE_NAME + RegionNames.ModuleRegion];
            regionManager.RegisterViewWithRegion(MODULE_NAME + RegionNames.ModuleRegion, () => this.unityContainer.Resolve<CustomersBrowseView>());
        }

    }
}
